package com.原型模式;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

/**
 * 父类：实现 Cloneable
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Sharpe implements Cloneable, Serializable {

    private String name;

    private int age;

    private String color;
    /**
     * 聚合了子类
     */
    private Children children;

    /**
     * 重写clone方法，并把修饰符改成public类型
     */
    @Override
    public Sharpe clone() throws CloneNotSupportedException {
        Sharpe sharpe = (Sharpe)super.clone();
        Children children = (Children)sharpe.getChildren().clone();
        sharpe.setChildren(children);
        return sharpe;
    }
}
